import Vue from 'vue'
import VueRouter from 'vue-router'
import tabberRoutes from './tabberRoutes'
import pageRoutes from './pageRoutes'
// 去除路由重定向报错
Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '',
    redirect: '/layout/index'
  },
  // 404

  ...tabberRoutes,
  ...pageRoutes,
  {
    path: '/404',
    name: '404',
    meta: {
      title: '404',
      keepAlive: true
    },
    component: () =>
      import(/* webpackChunkName: "404" */ '../views/404/index.vue')
  },
  {
    path: '*',
    name: '404',
    redirect: '/404'
  }
]

const router = new VueRouter({
  mode: 'hash', // history,hash 模式
  base: process.env.BASE_URL, // 基础路径
  routes // 路由集
})

export default router
